<cc:page type="normal" style="customize" showSidebar="false" showHeader="true" />
<cc>
try {
    CCService cs = new CCService(userInfo);
    List<CCObject> cxzdfz1= cs.cquery("zdfz","is_deleted='0'");
    List<CCObject> cxzdfz= cs.cquery("zdfz","is_deleted='0' limit 0,10");
    net.sf.json.JSONArray pq_arr = new net.sf.json.JSONArray();
    if(cxzdfz1.size()>0){
        for(int i=0;i<cxzdfz1.size();i++){
            String fzid = cxzdfz1.get(i).get("id")==null?"":cxzdfz1.get(i).get("id")+""; //撞单分组IS
            String fzmc = cxzdfz1.get(i).get("name")==null?"":cxzdfz1.get(i).get("name")+""; //撞单分组名称
            net.sf.json.JSONObject js_obj = new net.sf.json.JSONObject();
            js_obj.put("value",fzid);
            js_obj.put("label",fzmc);
            pq_arr.add(js_obj);
        }
    }
    net.sf.json.JSONArray js = net.sf.json.JSONArray.fromObject(cxzdfz);
</cc>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<!-- 
<link rel="stylesheet" href="resource/element-ui/lib/theme-chalk/index.css">

<script src="resource/js/vue2.js"></script>

<script src="resource/element-ui/lib/index.js"></script>
-->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.js"></script>

<body>
    <div id="app">
        <br/>
        <div style="text-align: center; font-size: 25px; font-weight: bold;">撞单分组合并</div>
        <br/>
        <div class="filter">
            <el-form :inline="true" :model="filter" class="demo-form-inline">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <el-form-item label="撞单分组">
                    <template>
                        <el-select v-model="zsfz" filterable multiple placeholder="请选择" @change = "selectOne">
                          <el-option
                            v-for="item in options_zsxm"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                      </template>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" size="small" @click="obtainCustomer">查询</el-button>
                </el-form-item>
                <el-form-item>
                    <el-col class="box-card text item">
                        <el-card shadow="hover">
                            {{'主撞单分组：'}}
                            {{zzdfz}}
                            <el-button style="float: right; padding: 3px 0" type="text" @click="hqzzdz">获取撞单组</el-button>
                        </el-card>
                    </el-col>
                </el-form-item>
                <el-form-item>
                    <el-col  class="box-card text item">
                        <el-card shadow="hover">
                            {{'合并撞单分组：'}}
                            {{hbzdfz}}
                            <el-button style="float: right; padding: 3px 0" type="text" @click="qkhbzdz">清空</el-button>
                            <el-button style="float: right; padding: 3px 0" type="text">|&nbsp</el-button>
                            <el-button style="float: right; padding: 3px 0" type="text" @click="hqhbzdz">获取撞单组</el-button>
                        </el-card>
                    </el-col>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" size="small" @click="hbkhz">合并</el-button>
                </el-form-item>
            </el-form>
        </div>
        <el-card shadow="hover">
        <div class="customTable">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="queryInfo.pagenum"
            :page-sizes="[2,,10,50,100,200]"
            :background=true
            :page-size="queryInfo.pagesize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="queryInfo.total">
        </el-pagination>
            <el-table :data="tableData" stripe style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55">
                </el-table-column>
                <el-table-column prop="name" label="分组名称" width="200">
                </el-table-column>
                <el-table-column prop="zsfqccname" label="招商分区" width="200">
                </el-table-column>
                <el-table-column prop="yxxxts" label="有效信息条数" width="150">
                </el-table-column>
                <el-table-column prop="wbkhts" label="外部客户条数" width="150">
                </el-table-column>
                <el-table-column prop="wgjts" label="未跟进天数" width="180">
                </el-table-column>
                <el-table-column prop="wlfts" label="未来访天数" width="180">
                </el-table-column>
            </el-table>
        </div>
        </el-card>

    </div>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    tableData:<cc:outprint>js</cc:outprint>,
                    pq_tab: '',
                    filter: {
                    },
                    zzdfz:'',
                    zzdfzId:'',
                    hbzdfz:'',
                    hbzdfzId:'',
                    options_zsxm: <cc:outprint>pq_arr</cc:outprint>,
                    options_bgxfz:'',
                    options_bgxxm:'',
                    yh_tab:'',
                    pq: '',
                    zsfz: '',
                    bzdfz:'',
                    bzdxm:'',
                    zsgw: '',
                    zszj:'<cc:outprint>userInfo.getUserId()</cc:outprint>',
                    multipleSelection:[],
                    jlsxfz:'',
                    queryInfo:{
                        query:'',
                        //当前第几页
                        pagenum: 1,
                        //每页几行
                        pagesize: 10,
                        //表单数据总数
                        total: <cc:outprint>cxzdfz1.size()</cc:outprint>
                    },
                }
            },

            methods: {
                //获取客户信息
                obtainCustomer(){
                    let that = this;
                    //console.log(this.jlsxfz);
                    axios.post('hbzdzcxym.jsp?zdfzid='+this.jlsxfz+'&mysl='+this.queryInfo.pagesize+'&djy='+this.queryInfo.pagenum)
					.then(function (response) {
                        let jszdz=response.data;
                        console.log(response.data[jszdz.length-1].zs);
                        that.tableData=response.data
                        that.queryInfo.total=Number(response.data[jszdz.length-1].zs)
					})
					.catch(function (error) {
						//console.log(error);
					});
                },
                hqzzdz(){
                    let that = this;
                    if(this.multipleSelection.length==1){
                        //console.log(this.multipleSelection[0].name);
                        this.zzdfz=this.multipleSelection[0].name
                        this.zzdfzId=this.multipleSelection[0].id
                        that.obtainCustomer();
                    }else{
                        alert("请选择一个且仅一个主撞单分组");
                    }
                },
                hqhbzdz(){
                    let that = this;
                    if(this.multipleSelection.length>0){
                        let zdfzmc='';
                        let zdfzmcId='';
                        for(let i=0;i<this.multipleSelection.length;i++){
                            if(i==0){
                                zdfzmc+=this.multipleSelection[i].name
                                zdfzmcId+="'"+this.multipleSelection[i].id+"'"
                            }else{
                                zdfzmc+=";"+this.multipleSelection[i].name
                                zdfzmcId+=","+"'"+this.multipleSelection[i].id+"'"
                            }
                        }
                        this.hbzdfz=zdfzmc;
                        this.hbzdfzId=zdfzmcId;
                        that.obtainCustomer();
                    }else{
                        alert("请至少选择一个撞单分组");
                    }
                },
                qkhbzdz(){
                    this.hbzdfz='';
                    this.hbzdfzId='';
                },
                hbkhz(){
                    if(this.zzdfzId.length>0){//主撞单分组
                        if(this.hbzdfzId.length>0){//合并撞单分组
							//console.log(this.zzdfzId);
							//console.log(this.hbzdfzId);
							axios.post('hbzdfzht.jsp?zzdz='+this.zzdfzId+'&hbzdz='+this.hbzdfzId)
							.then(function (response) {
								//console.log(response.data);
                                alert(response.data);
							})
							.catch(function (error) {
								//console.log(error);
							});
                        }else{
                            alert("请选择合并撞单分组");
                        }
                    }else{
                        alert("请选择主撞单分组");
                    }
                },
                //分配选中客户
                select() {
                    let that = this;
                    let val = this.multipleSelection;
                    let pjkhid='';
                    if(val.length==0){
                        alert("请选择分配客户");
                    }else if(this.zsgw==''){
                        alert("请选择分配顾问");
                    }else{
                        for(let i=0;i<val.length;i++){
                            pjkhid+= val[i].zskhid+',';
                        }
                        //console.log(pjkhid);
                        //console.log(this.zsgw);
                        axios.post('clghfp.jsp?khid='+pjkhid+'&gwid='+this.zsgw+'&xmid='+this.bzdxm+'&fzid='+this.zsxm)
                        .then(function (response) {
                            //console.log(response);
                            alert(response.data);
                            that.obtainCustomer();
                        })
                        .catch(function (error) {
                            //console.log(error);
                        });
                    }
                },
                //获取招商项目
                selectOne(item) {
                    let val= this.zsfz;
                    let pjfzid='';
                    //console.log(val);
                    if(val.length==0){
                        this.jlsxfz='';
                    }else if(val.length>0){
                        for(let i=0;i<val.length;i++){
                            if(i==0){
                                pjfzid+='\''+this.zsfz[i]+'\''
                            }else{
                                pjfzid+=','+'\''+this.zsfz[i]+'\''
                            }
                        }
                    }
                    this.jlsxfz=pjfzid;
                    //console.log(this.jlsxfz);
                },
                selectOne1(item){
                    //console.log(this.bzdxm);
                    let that = this;
                    axios.post('yzyfqhqxm.jsp?id='+this.bzdxm)
                    .then(function (response) {
                        that.yh_tab = response.data
                    })
                    .catch(function (error) {
                        //console.log(error);
                    });
                },
                //获取招商顾问
                selecttwo(item) {
                    //console.log(item);
                },
                //获取选中客户ID
                handleSelectionChange(val) {
                        this.multipleSelection=val;
                        //console.log(this.multipleSelection);
                },
                //获取分页每页数量
                handleSizeChange(newSize){
                    console.log(newSize);
                    this.queryInfo.pagesize=newSize;
                    this.obtainCustomer();
                },
                //获取分页页码
                handleCurrentChange(newPage){
                    console.log(newPage);
                    this.queryInfo.pagenum=newPage;
                    this.obtainCustomer();
                },
            }
        })
    </script>
</body>
</html>
<cc>
} catch (Exception e) {
    out.print(e);
}
</cc>